package com.catazy.demo

import android.util.Log
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.catazy.mvvmlib.ext.hexToByteArray
import com.catazy.mvvmlib.ext.toHexString

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
 * Instrumented test, which will execute on an Android device.
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
    @Test
    fun useAppContext() {
        // Context of the app under test.
        val appContext = InstrumentationRegistry.getInstrumentation().targetContext
        assertEquals("com.catazy.mvvmlib", appContext.packageName)
    }

    @Test
    fun testByteToHex() {
        val bytes = byteArrayOf(0x01, 0x02, 0x03, 0x04)
        val hex = bytes.toHexString()
        Log.i("test", "hex: $hex")
        print("hex: $hex")
    }

    @Test
    fun hexToByte(){
        val hex = "01020304"
        val bytes = hex.hexToByteArray()
        Log.i("test", "bytes: $bytes")
        val str = bytes.toHexString()
        Log.i("test", "hex: $str")
        print("bytes: $bytes")
    }
}